home *** CD-ROM | disk | FTP | other *** search
- \bigskip
- \bigskip
- {\magonebf 6.1.5 Circles (circle)}
-
- {\bf 1. Definition}
-
- An instance $C$ of the data type $circle$ is a circle in the two-dimensional
- plane, i.e., the set of points having a certain distance $r$ from a given
- point $p$. $r$ is called the radius and $p$ is called the center of $C$.
- The circle with center $(0,0)$ and radius $0$ is called the empty circle.
-
- \def\name{$circle$}
- \def\type{$circle$}
-
- {\bf 2. Creation}
-
- a) \create C (point\ p,\ double\ r)
-
- b) \create C (double\ x,\ double\ y,\ double\ r)
-
- c) \create C {}
-
-
- introduces a variable $C$ of type $circle$. $C$ is initialized to the circle
- with center $p$ and radius $r$ (variant a), to the circle with center $(x,y)$
- and radius $r$ (variant b), or to the empty circle (variant c).
-
-
- \bigskip
- {\bf 3. Operations}
-
- \medskip
- \+\cleartabs & \hskip 2.4truecm & \hskip 5truecm &\cr
- \+\op double radius {}
- {returns the radius of \var.}
- \smallskip
- \+\op point center {}
- {returns the center of \var.}
- \smallskip
- \+\op list\<point\> intersection {line\ l}
- {returns $C \cap l$ as a list of points.}
- \smallskip
- \+\op list\<point\> intersection {segment\ s}
- {returns $C \cap s$ as a list of points.}
- \smallskip
- \+\op list\<point\> intersection {circle\ D}
- {returns $C \cap D$ as a list of points.}
- \smallskip
- \+\op segment left\_tangent {point\ p}
- {returns the line segment starting in $p$ tangent}
- \+\nop {to \var\ and left of segment $[p,C.center()]$.}
- \smallskip
- \+\op segment right\_tangent {point\ p}
- {returns the line segment starting in $p$ tangent}
- \+\nop {to \var\ and right of segment $[p,C.center()]$.}
- \smallskip
- \+\op double distance {point\ p}
- {returns the distance between \var\ and $p$}
- \+\nop {(negative if $p$ inside \var).}
- \smallskip
- \+\op double distance {line\ l}
- {returns the distance between \var\ and $l$ }
- \+\nop {(negative if $l$ intersects \var).}
- \smallskip
- \+\op double distance {circle\ D}
- {returns the distance between \var\ and $D$}
- \+\nop {(negative if $D$ intersects \var).}
- \smallskip
- \+\op bool inside {point\ p}
- {returns true if $P$ lies inside of \var,}
- \+\nop {false otherwise.}
- \smallskip
- \+\op bool outside {point\ p}
- {returns !\var.inside($p$).}
- \smallskip
- \+\op circle translate {vector\ v}
- {returns $C+v$, i.e., the circle created by}
- \+\nop {translating $C$ by vector $v$. \precond }
- \+\nop {$v$.dim = 2.}
- \smallskip
- \+\op circle translate {double\ \alpha,\ double\ d} {}
- \+\nop {returns the circle created by a translation of}
- \+\nop {$C$ in direction $\alpha$ by distance $d$.}
- \smallskip
- \+\op circle rotate {point\ q,\ double\ \alpha} {}
- \+\nop {returns the circle created by a rotation of $C$}
- \+\nop {about point $q$ by angle $\alpha$.}
- \smallskip
-
- \bigskip
- {\bf 4. Operators }
- \medskip
- \+&$bool$ &$circle$ == $circle$ &test for equality\cr
- \smallskip
- \+&$bool$ &$circle$\ !=\ $circle$ &test for inequality\cr
-
- \vfill\eject
-